# -*- coding: utf-8 -*-

import sys

import util

from scaws import AWS
from scdb import DB01


APP_PATH = sys.modules['__main__'].WORKER_PATH
TASK_NAME = sys.modules['__main__'].TASK_NAME
TASK_FULL_NAME = sys.modules['__main__'].TASK_FULL_NAME

DATA_PATH = '%s/../scworker_data' % APP_PATH
TASK_PATH = '%s/%s' % (DATA_PATH, TASK_FULL_NAME)
# STATE_DATA_PATH = '%s/state' % (TASK_PATH)
# STATE_FILE_NAME = '%s/state.dat' % STATE_DATA_PATH
LOG_PATH = '%s/log' % (TASK_PATH)

LOGGER_NAME = 'data'
LOGGING_CFG = eval(util.load_file('%s/logging.conf' % util.get_file_path(__file__)).replace('@log_path', LOG_PATH))

PREPARE_FOR_DIRS = [LOG_PATH]

CFG = {
    'processor': 'crawl_task.CrawlTask',
    'logger_name': LOGGER_NAME,
    'rest_time': 6,
    'sleep_time': 6,
    'pgsql_table': 'test_xf_news',
    'dynamodb_table': 'test_xf_news',
    'components': [
        {
            'name': 'conveyor',
            'class_name': 'aws_sqs.AwsSqs',
            'cfg': {
                'aws': AWS,
                'queue_used_for_receive': 'smoke_test',
                'receive_args': {
                    'MaxNumberOfMessages': 1,
                    'WaitTimeSeconds': 6
                }
            }
        },
        {
            'name': 'sqlexecutor',
            'class_name': 'pgsql.PostgreSQL',
            'cfg': {
                'conn_args': DB01
            }
        },
        {
            'name': 'dynamodb',
            'class_name': 'aws_dynamodb.AwsDynamoDB',
            'cfg': {
                'aws': AWS
            }
        }
    ]
}
